﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;
using System.Collections.ObjectModel;


namespace MoneyManagerNET.Presentation.ViewModel
{
    using Model;
using System.Collections.Specialized;
using System.Windows.Data;
using System.Collections;
    using MoneyManagerNET.Presentation.ViewModel.Base;

    public class StockAccountListViewModel:ViewModelBase
    {
            ICollectionView _StockAccountListVM;
            public ICollectionView StockAccountListVM { get { return _StockAccountListVM; } set { _StockAccountListVM =value; OnChange("ContragentListVM"); } }

            ObservableCollection<IContragent> contragentList = null;

            public INotifyCollectionChanged ContragentList
            {
                get { return contragentList; }
                set { contragentList = (ObservableCollection<IContragent>)value; StockAccountListVM = new CollectionView(value as IEnumerable); OnChange("ContragentList"); }
            }

            public StockAccountListViewModel()
            {
                this.ContragentList =new ObservableCollection<IContragent>( App.Storage.Select<IContragent>().ToList());
            }

            public IStockAccount Selected { get { return StockAccountListVM.CurrentItem as IStockAccount; } set { StockAccountListVM.MoveCurrentTo(value); } }
    }
}
